<!DOCTYPE html>
<html>
<!--
Copyright 2011 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.

-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.storage.mechanism.PrefixedMechanism</title>
<script src="../../base.js"></script>
<script>
  goog.require('goog.storage.mechanism.iterablemechanism_test');
  goog.require('goog.storage.mechanism.prefixedmechanism_test');
  goog.require('goog.storage.mechanism.mechanism_test');
  goog.require('goog.storage.mechanism.HTML5LocalStorage');
  goog.require('goog.storage.mechanism.PrefixedMechanism');
  goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<script>

function testBasicOperations() {
  var submechanism = new goog.storage.mechanism.HTML5LocalStorage();
  if (submechanism.isAvailable()) {
    var mechanism = new goog.storage.mechanism.PrefixedMechanism(
        submechanism, 'foo');
    goog.storage.mechanism.mechanism_test.runBasicTests(mechanism);
  }
}

function testIterableOperations() {
  var submechanism = new goog.storage.mechanism.HTML5LocalStorage();
  if (submechanism.isAvailable()) {
    var mechanism = new goog.storage.mechanism.PrefixedMechanism(
        submechanism, 'foo');
    goog.storage.mechanism.iterablemechanism_test.runIterableTests(mechanism);
  }
}

function testSharing() {
  var submechanismA = new goog.storage.mechanism.HTML5LocalStorage();
  if (submechanismA.isAvailable()) {
    var submechanismB = new goog.storage.mechanism.HTML5LocalStorage();
    assertTrue(submechanismB.isAvailable());

    var mechanismA = new goog.storage.mechanism.PrefixedMechanism(
        submechanismA, 'foo');
    var mechanismB = new goog.storage.mechanism.PrefixedMechanism(
        submechanismB, 'foo');

    goog.storage.mechanism.prefixedmechanism_test.runSharingTests(
        mechanismA, mechanismB);
  }
}

function testSeparation() {
  var submechanism = new goog.storage.mechanism.HTML5LocalStorage();
  if (submechanism.isAvailable()) {
    var mechanismA = new goog.storage.mechanism.PrefixedMechanism(
        submechanism, 'fooA');
    var mechanismB = new goog.storage.mechanism.PrefixedMechanism(
        submechanism, 'fooB');

    goog.storage.mechanism.prefixedmechanism_test.runSeparationTests(
        mechanismA, mechanismB);
  }
}

</script>
</body>
</html>
